import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:macnov/common/loading.dart';
import 'package:macnov/role_owner/wallet/components/physicalcard.dart';

import 'package:macnov/stores/wallet.dart';
import 'package:macnov/utils/colorUtil.dart';


class PhysicalCardScene extends StatefulWidget {
  @override
  _PhysicalCardSceneState createState() => _PhysicalCardSceneState();
}

class _PhysicalCardSceneState extends State<PhysicalCardScene> {
  @override
  void initState() {
    super.initState();
    walletStore.loadPhysicalCard();
  }

  Widget _buildAddress() {
    return Container(
        padding: EdgeInsets.only(top: 20, left: 40, right: 40),
        child: Column(
          children: <Widget>[
            Text(
              'BILLING ADDRESS',
              style:
                  TextStyle(color: ColorsUtil.hexColor(0x999999), fontSize: 14),
            ),
            Padding(
                padding: EdgeInsets.only(top: 20),
                child: Text(
                  walletStore.physicalCard.address +','+ walletStore.physicalCard.city +','+ walletStore.physicalCard.state,
                  strutStyle: StrutStyle(height: 2),
                  textAlign: TextAlign.center,
                  style: TextStyle(
                      color: ColorsUtil.hexColor(0x141414), fontSize: 18),
                ))
          ],
        ));
  }

  List<Widget> _renderPage(physicalCard) {
    if (physicalCard == null) return <Widget>[Loading()];
    return <Widget>[
      new PhysicalCard(),
      _buildAddress(),
    ];
  }

  @override
  Widget build(BuildContext context) {
    return Observer(
      builder: (_) => Container(
        color: Colors.white,
        child: ListView(
          shrinkWrap: true,
          children: _renderPage(walletStore.physicalCard),
        ),
      ),
    );
  }
}
